﻿<%@ WebHandler Language="C#" Class="peoplePIC" %>

using System;
using System.Web;
using System.IO;
using CCH.DAO;
using CCH.Entity;

public class peoplePIC : IHttpHandler
{

    NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
    
    public void ProcessRequest(HttpContext context) 
    {
        
        //取醫生pic path
        string filepath = context.Request["doc_picpath"];

        byte[] img_bin=null;

        try
        {
            img_bin = File.ReadAllBytes(filepath);
        }
        catch
        {
            img_bin = File.ReadAllBytes(context.Server.MapPath("~/image/noimage.jpg"));
        }
            
        //輸出
        context.Response.ContentType = "image/jpeg";
        context.Response.BinaryWrite(img_bin);
        context.Response.Flush();
        context.Response.End();
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}